﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _01复习
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //操作 数据库的类：
            //
            //从数据库 ManagerInfo 查询数据，显示到datagridview上


            #region 手动写查询代码
            //// 0.构造集合的类
            //List<ManagerInfo> list = new List<ManagerInfo>();
            ////1.连接字符串
            //string connStr = @"data source=E:\GitWorks\ItcastCater\ItcastCater\ItcastCater.db;version=3";
            ////2 创建连接对象
            //using (SQLiteConnection conn = new SQLiteConnection(connStr))
            //{
            //    //3 创建Command对象
            //    SQLiteCommand cmd = new SQLiteCommand("select * from ManagerInfo", conn);
            //    //4 打开连接
            //    conn.Open();
            //    //5 执行命令
            //    SQLiteDataReader reader = cmd.ExecuteReader();
            //    //6 读取
            //    if (reader.HasRows)
            //    {
            //        while (reader.Read())
            //        {
            //            list.Add(new ManagerInfo()
            //            {
            //                Mid = Convert.ToInt32(reader["mid"]),
            //                Mname = reader["Mname"].ToString(),
            //                Mpwd = reader["Mpwd"].ToString(),
            //                Mtype = Convert.ToInt32(reader["mtype"])

            //            });
            //        }
            //    }
            //    reader.Close();

            //}
            ////7.将显示到dataGridview上
            //dataGridView1.DataSource = list;
            #endregion


            dataGridView1.DataSource = SqliteHelper.GetDataTable("select * from ManagerInfo");

        }

        private void SetText()
        {

        }
    }
}
